//
//  CompanySelfCheckModel.m
//  u76ho
//
//  Created by m-air-01 on 16/1/22.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "CompanySelfCheckModel.h"

@implementation CompanySelfCheckModel
-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}
-(void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqualToString:@"errmsg"]) {
        NSArray * arr = value;
        NSMutableArray * mArr = [[NSMutableArray alloc]init];
        for (int i = 0; i<arr.count; i++) {
            NSDictionary * dic = arr[i];
            CompanySelfCheckOneModel * model = [[CompanySelfCheckOneModel alloc]initDic:dic];
            [mArr addObject:model];
        }
        _dataArr = mArr;
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}
@end

//*************************************************
@implementation CompanySelfCheckOneModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        _answerArr = [[NSMutableArray alloc]initWithArray:@[@"",@"",@"",@"",@"",@""]];
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
//        answer1 = "A\U3001\U5df2\U5c3d\U6211\U6240\U80fd";
//        answer2 = "B\U3001\U672a\U80fd\U5b8c\U5168\U53d1\U6325";
//        answer3 = "C\U3001\U53d1\U6325\U673a\U4f1a\U4e0d\U591a";
//        answer4 = "D\U3001\U6ca1\U611f\U89c9";
//        answer5 = "E\U3001\U5bf9\U6211\U7684\U80fd\U529b\U6709\U4e9b\U57cb\U6ca1";
//        answer6 = "F\U3001\U6ca1\U6709\U80fd\U8ba9\U6211\U65bd\U5c55\U7684\U673a\U4f1a";
//        answer7 = "<null>";

        if ([key isEqualToString:@"answer1"]) {
            [_answerArr replaceObjectAtIndex:0 withObject:value];
        }
        else if ([key isEqualToString:@"answer2"])
        {
            [_answerArr replaceObjectAtIndex:1 withObject:value];

        }
        else if ([key isEqualToString:@"answer3"])
        {
            [_answerArr replaceObjectAtIndex:2 withObject:value];

        }
        else if ([key isEqualToString:@"answer4"])
        {
            [_answerArr replaceObjectAtIndex:3 withObject:value];

        }
        else if ([key isEqualToString:@"answer5"])
        {
            [_answerArr replaceObjectAtIndex:4 withObject:value];

        }
        else if ([key isEqualToString:@"answer6"])
        {
            [_answerArr replaceObjectAtIndex:5 withObject:value];

        }
        else if ([key isEqualToString:@"answer7"])
        {
            [_answerArr addObject:value];
        }
        else
        {
            [super setValue:value forKey:key];
        }
        
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end